// entity_player

local entity_player = Assault.Entities:New("entity_player")

// On entity created

function entity_player:OnEntitySpawn()
	self:EntitySetMass(75)
	self:EntitySetHealth(100)
end

// On entity think

function entity_player:OnEntityThink()
	local Position = self:EntityGetPosition()
	local Rotation = self:EntityGetRotation()
	
	// Rotation
	
	if (Assault.Client:KeyDown(IN_MOVERIGHT)) then
		self:EntitySetRotation(Rotation + 5)
	elseif (Assault.Client:KeyDown(IN_MOVELEFT)) then
		self:EntitySetRotation(Rotation - 5)
	end
	
	// Player is holding down the forward key
	
	if (Assault.Client:KeyDown(IN_FORWARD)) then
		self:EntitySetForce(Rotation, 2.5)
	end
end

// On player mouse pressed

function entity_player:OnPlayerMousePressed(Code)
	// Check for the left mouse button
	
	if (Code == MOUSE_LEFT) then
		self:EntityEmitSound("weapons/pistol/pistol_fire2.wav", self)
		
		// Entity shoot bullets
		
		self:EntityShootBullets(5, self:EntityGetRotation(), 1, 0, 10, 50, Color(255, 215, 0, 255))
	end
end

// On entity break

function entity_player:OnEntityTakeDamage(Damage)
	local Position = self:EntityGetPositionCenter()
	
	// Blood
	
	Assault.Entities.EntitiesQuickCreate("effect_blood", Position, false, false)
	
	// Return false
	
	return false
end

// Create

entity_player:Create()